package com.ruoyi.finance.service.impl;

import java.util.List;

import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.finance.mapper.AdvanceMapper;
import com.ruoyi.finance.domain.Advance;
import com.ruoyi.finance.service.IAdvanceService;

/**
 * 预付款Service业务层处理
 * 
 * @author ruoyi
 * @date 2023-11-24
 */
@Service
public class AdvanceServiceImpl implements IAdvanceService 
{
    @Autowired
    private AdvanceMapper advanceMapper;

    /**
     * 查询预付款
     * 
     * @param requestId 预付款主键
     * @return 预付款
     */
    @Override
    public Advance selectAdvanceByAdvanceId(Long requestId)
    {
        return advanceMapper.selectAdvanceByAdvanceId(requestId);
    }

    /**
     * 查询预付款列表
     * 
     * @param advance 预付款
     * @return 预付款
     */
    @Override
    public List<Advance> selectAdvanceList(Advance advance)
    {
        return advanceMapper.selectAdvanceList(advance);
    }



    /**
     * 修改预付款
     * 
     * @param advance 预付款
     * @return 结果
     */
    @Override
    public int updateAdvance(Advance advance)
    {
        advance.setUpdateTime(DateUtils.getNowDate());
        return advanceMapper.updateAdvance(advance);
    }

    /**
     * 批量删除预付款
     *
     * @param requestIds 需要删除的预付款主键
     * @return 结果
     */
    @Override
    public int deleteAdvanceByAdvanceIds(Long[] requestIds)
    {
        return advanceMapper.deleteAdvanceByAdvanceIds(requestIds);
    }

    /**
     * 删除预付款信息
     *
     * @param advanceId 预付款主键
     * @return 结果
     */
    @Override
    public int deleteAdvanceByAdvanceId(Long advanceId)
    {
        return advanceMapper.deleteAdvanceByAdvanceId(advanceId);
    }

    @Override
    public int updateAdvanceApplicant(Long[] requestIds, boolean flay, String applicant) {
        if (flay){
            return advanceMapper.updateAdvanceApplicant(requestIds, Constants.SUCCESS,applicant);
        }else{
            return advanceMapper.updateAdvanceApplicant(requestIds,Constants.FAIL,applicant);
        }
    }

    @Override
    public List<Advance> selectAdvanceByRequestId(Long[] requestIds) {
        return advanceMapper.selectAdvanceByRequestId(requestIds);
    }

    @Override
    public int updateAdvanceByAdvanceStatus(Long[] requestIds) {
        return advanceMapper.updateAdvanceByAdvanceStatus(requestIds);
    }
}
